<?php


namespace app\pay\controller;

use app\pay\service\Hqkjsk;
use think\Controller;
use app\pay\service\Hqxe;
use app\pay\service\Hqdee;
use think\Db;
class Test extends Controller
{
    public function index(){
    	//查询收款订单
		$res = (new Payhqdf)->

//        $userlist = Db::name("user")->select();
//        $list = $this->tree($userlist,'433');
//        halt($list);

    }

    public function tree($list,$uid){
    	$tree=[];
    	foreach ($list as $k=>$v){
    		if($v["user_pid"]==$uid){
    			$tree[]=$v;
    			$tree=array_merge($tree,$this->tree($list,$v["user_id"]));
			}
		}
    	return $tree;
	}


	public function kjReg(){
		$param = [
			"ordersn" => "jskj_41905120000440",//流水号
			"dsorderid" => "jskj_41905120000440",//商户订单号
			"futureRateValue" => "0.55",//每笔费率
			"fixAmount" => "200",//单笔价格
			"accountName" => "芦鸿明",//真实姓名
			"idcard" => "330227197310032737",//身份证号
			"mobile" => "13586507223",//预留手机号

			"settleBankCard" => "6217001590010774506",//收款银行卡号
			"settleBankName" => "中国银行",//收款银行卡名称:民生银行
			"settleBankCode" => "BOC",//银行代码:CMBC
		];
		//halt($param);
		$regRes = (new Hqkjsk)->register($param);
		halt($regRes);
	}

	public function deBalance(){
		$data=[
			"ordersn"=>get_order_sn("", "423"),//流水号
			"dsorderid"=>get_order_sn("", "423"),//商户订单号
			"subMerchantNo"=>"200041181899",//子商户号
		];
		//halt($data);
		$res = (new Hqdee)->queryBalance($data);
		halt($res);
	}

	public function deQueryOrder(){
		$data=[
			"ordersn"=>get_order_sn("", "423"),//流水号
			"dsorderid"=>"P1905100759064877500134200",//商户订单号
			"transtype"=>"85",//交易类型85交易86代付
		];
		//halt($data);
		$res = (new Hqdee)->queryOrder($data);
		halt($res);
	}
//	public function dePay(){
//		//调用接口开始还款
//		$data['ordersn'] = get_order_sn("", $uid); //流水号
//		$data['dsorderid'] = "P1905100759064877500134200";//商户订单号
//		$data['subMerchantNo'] = "200040057846";//子商户账号
//		$data['amount'] = ($plan['plan_money']) * 100;//金额
//		$data['fixAmount'] = $plan['plan_fee'] * 100;//单笔价格以分为单位，不能有小数点
//		$data["bankcard"] = "6222530621091995";//银行卡号
//		$data["mobile"] = "18638109929";//手机号
//		$data["cardType"] = "CREDIT";//卡类型xuan借记卡：DEBIT  贷记卡：CREDIT
//		$data['notifyUrl'] = config("app_host") . '/pay/Payhqde/pay_notify';//回调地址
//		return $this->doPay($data, 'withDraw');
//	}
	public function withDraw()
	{
		$data = [
			"ordersn" => get_order_sn("", "423"),//流水号
			"dsorderid" => get_order_sn("", "423"),//商户订单号
//			"subMerchantNo" => "425824232161",//李泽华
//			"bindId" => "BK6413203832",//李泽华
			"subMerchantNo" => "425824232161",//张建春
			"bindId" => "BK6413203832",//张建春
			"userFee" => 1*100,//交易手续费
			"amount" => 741.1 * 100,//金额
			"notifyUrl"=>'http://' . $_SERVER['HTTP_HOST'] . '/pay/Huidiao/index'
		];
		//halt($data);
		$res = (new Hqxe)->withDraw($data);
		halt($res);
	}

	public function queryBalance()
	{
		$data = [
			"ordersn" => get_order_sn("", "423"),//流水号
			"dsorderid" => get_order_sn("", "423"),//商户订单号
			//"subMerchantNo" => "478376376165",
			//"bindId" => "BK6424262280"
			"subMerchantNo" => "523460306223",//李泽华
			"bindId" => "BK4700446600",//李泽华
		];
		//halt($data);
		$res = (new Hqxe)->queryBalance($data);
		halt($res);
	}

	public function query_order()
	{
		$data = [
			"ordersn" => get_order_sn("", "423"),//流水号
			"dsorderid"=>"C19051512584086548044035",//商户订单号扣款
			//"dsorderid" => "C1905070627375322200092803",//商户订单号还款
			"transtype" => "134",//交易类型133交易，134代付
		];
		//halt($data);
		$res = (new Hqxe)->queryOrder($data);
		halt($res);
	}

	//扣款
	public function kk()
	{
		//调用接口开始扣款
		$data['ordersn'] = "19051211370937876044066"; //流水号
		$data['dsorderid'] = "P1905121050475901500055600";//商户订单号
		$data['subMerchantNo'] = "523460306223";//子商户账号
		$data['bindId'] = "BK4700446600";//绑卡成功返回的bindId
		$data["amount"]=120;//金额以分为单位，不能有小数
		$data['userFee'] = 10;//手续费
		$data['province'] = (new Base)->getCityCodeByRegion("浙江省-宁波市");//消费城市
		//$data['mcc'] = "";//行业xuan
		$data['notifyUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . '/pay/Huidiao/index';//回调地址


		//换卡之后
		//调用接口开始扣款
//		$data['ordersn'] = get_order_sn("", "423"); //流水号
//		$data['dsorderid'] = get_order_sn("P", "423");//商户订单号
//		$data['subMerchantNo'] = "523460306223";//子商户账号
//		$data['bindId'] = "BK4700446600";//绑卡成功返回的bindId
//		$data["amount"]=120;//金额以分为单位，不能有小数
//		$data['userFee'] = 75;//手续费
//		$data['province'] = (new Base)->getCityCodeByRegion("浙江省-宁波市");//消费城市
//		//$data['mcc'] = "";//行业xuan
//		$data['notifyUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . '/pay/Huidiao/index';//回调地址
		//halt($data);
		$res = (new Hqxe)->pay($data);
		halt($res);
	}

	//注册
	public function reg()
	{
		$param = [
			"ordersn" => "hqxe21904240000423",
			"dsorderid" => "hqxe21904240000423",
			"bankcard" => "5176369913383457",
			"username" => "于汇洋",
			"idcard" => "410423198410302511",
			"mobile" => "18638109929",
			"futureRateValue" => "0.0075",
			"fixAmount" => "1",
		];
		//halt($param);
		$regRes = (new Hqxe)->register($param);
	}
}